﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using Domain;
namespace DataAcess
{
    public class HotelData
    {
        private String literalConexion;

        public HotelData(String literalConexion)
        {
            this.literalConexion = literalConexion;
        }

        public Hotel GetDatosHotel(int idHotel)
        {
            String SqlSelect = "SELECT * "
                              + "FROM Hotel "
                              + "WHERE id_hotel= " + idHotel;

            SqlConnection conexion = new SqlConnection(literalConexion);
            SqlCommand cmdSelect = new SqlCommand(SqlSelect, conexion);
            conexion.Open();
            SqlDataReader reader = cmdSelect.ExecuteReader();
            Hotel hotel = new Hotel();

            if (reader.Read())
            {
                hotel.IdHotel = reader.GetInt32(0);
                hotel.Nombre = reader.GetString(1);
                hotel.Telefono1 = reader.GetString(2);
                hotel.Telefono2 = reader.GetString(3);
                hotel.CodigoPostal = reader.GetString(4);
                hotel.Email = reader.GetString(5);
            }
            conexion.Close();
            return hotel;
        }

    }
}